<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Title</title>
    <!--    导入BootStrap的css文件-->
    <link rel="stylesheet" href="bootstrap3/css/bootstrap.min.css">
    <link rel="stylesheet" href="bootstrap3/css/bootoast.css">
    <!--    导入jquery-->
    <script src="bootstrap3/jquery.js" type="text/javascript" charset="utf-8"></script>
    <!--    导入bootstrap中的js文件-->
    <script src="bootstrap3/js/bootoast.js" type="text/javascript" charset="utf-8"></script>
    <script src="bootstrap3/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <style>
        #u1{
            padding: 20px;
            border-radius: 15px;
            background-image: url("img/weimei2.jpg");
            margin-top: 300px;
            background-size: cover;
        }
        body{
            background-image: url("img/weimei1.jpg");
            background-size: cover;
        }
    </style>
    <script>
        $(function (){
            $('#btnLogin').click(function (){
                if ($('#account').val()=='') {
                    bootoast({
                        message:'账号不能为空',
                        type:'danger',
                        position:'top',
                        timeout:2
                    });
                }else {
                    if ($('#pass').val()=='') {
                        bootoast({
                            message:'密码不能为空',
                            type:'danger',
                            position:'top',
                            timeout:2
                        });
                }
                };
                //账号密码都正确
                $.ajax({
                    url:'login',
                    type:'post',
                    cache:false,
                    data:{
                        account:$('#account').val(),
                        pass:$('#pass').val()
                    },
                    dataType:'json',
                    success:function (rst){
                        if (rst.code==-1){
                            bootoast({
                                message:rst.msg,
                                type:'danger',
                                position:'top',
                                timeout:2
                            });
                        }else {
                            bootoast({
                                message:rst.msg,
                                type:'success',
                                position:'top',
                                timeout:2
                            });
                            //登录成功之后用户信息的保存
                            sessionStorage.setItem("adminId",rst.data.id);
                            sessionStorage.setItem("nickName",rst.data.nickName);
                            //跳转页面
                            setTimeout(function (){
                                location.href="921action.html";
                            },1000);
                        }
                    },
                    error:function (err){
                        alert(err);
                    }
                });
            });
        });
    </script>
</head>
<body>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-4 col-sm-offset-4">
<!--            垂直表单-->
            <form class="form-horizontal">
                <div id="u1">
                    <h2 class="text-center">狗熊玲图书商城登录</h2>
                    <div class="form-group" >
                        <label for="account" class="col-sm-2  control-label">账号:</label>
                        <div class="  col-sm-8">
                            <input type="account" id="account" name="" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="pass" class="col-sm-2  control-label">密码:</label>
                        <div class="col-sm-8">
                            <input type="password" id="pass" name="" class="form-control">
                        </div>
                </div>
                    <div class="text-right">
                        <input type="button" id="btnLogin" class="btn btn-info" value="登录">
                    </div>
                </div>

            </form>

        </div>
    </div>
</div>
</body>
</html>